﻿using Ewell.BizComponent.UI.Reserve.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Ewell.BizComponent.UI.Reserve.Views
{
    /// <summary>
    /// OutpReserveView.xaml 的交互逻辑
    /// </summary>
    public partial class OutpReserveView : UserControl
    {
        public OutpReserveVm outpReserveVm { get; set; }
        public OutpReserveView()
        {
            InitializeComponent();
        }

        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            (this.DataContext as OutpReserveVm).visitDate = DateTime.Today.AddDays(1);
            (this.DataContext as OutpReserveVm).QueryESProvider.Execute(this);
            (this.DataContext as OutpReserveVm).QuerySchedule.Execute(this);
        }

        private void ComboBox_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.Key is Key.Enter or Key.Space or Key.Up or Key.Down or Key.Left or Key.Right) return;
            (sender as ComboBox).IsDropDownOpen = true;
        }

        private void ComboBox_DropDownClosed(object sender, EventArgs e)
        {
            if(sender is ComboBox)
            {
                if((sender as ComboBox).SelectedItem != null)
                {
                    (sender as ComboBox).Text= (((ComboBox)sender).SelectedItem as EsProviderInfoVm).esProviderName;
                }
            }
        }
    }
}
